/*
 * @Author: xushuhao
 * @Email: xshmouse@163.com
 * @Date: 2020-04-30 15:16:01
 * @Last Modified by: xushuhao
 * @Last Modified time: 2020-05-08 12:01:29
 * @Description: 播放器DEMO 默认大屏
 */

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_code_framework/base/base_main_tabbar.dart';
import 'package:flutter_code_framework/route/route_transition.dart';
import 'package:flutter_code_framework/widgets/x_video_player.dart';
import 'package:auto_orientation/auto_orientation.dart';

class VideoPlayer extends StatefulWidget {
  String sourceType;
  List<PlayerInputInstance> path;

  VideoPlayer({
    Key key,
    this.sourceType,
    this.path = null,
    
  }) : super(key: key);
  @override
  VideoPlayerState createState() {
    return VideoPlayerState();
  }
}

class VideoPlayerState extends State<VideoPlayer> {
  @override
  Widget build(BuildContext context) {
    //全屏 强制横屏
    AutoOrientation.landscapeRightMode();
    //启动横屏陀螺仪
    AutoOrientation.landscapeAutoMode();
    // ignore: missing_return
    return WillPopScope(child: XVideoPlayer(isPlay: true, path: widget.path, sourceType: widget.sourceType,),onWillPop:(){
      RouteTransition(BaseMainTabbarPage()).pushAndRemoveUntilTransRoute(context);
    });
  }
}

